package com.wp.common.advice;

import com.wp.common.exception.ScException;
import com.wp.common.vo.ExceptionResult;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * 拦截异常统一处理
 *
 * @author wp
 * @create 2019-03-03 11:51
 */
@ControllerAdvice
public class BasicExceptionHandler {

    @ExceptionHandler(ScException.class)
    public ResponseEntity<ExceptionResult> handleException(ScException e) {
        return ResponseEntity.status(e.getExceptionEnum().value())
                .body(new ExceptionResult(e.getExceptionEnum()));
    }

}
